package com.googlecode.archimedes.filegen.model;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.googlecode.archimedes.util.GuidGenerator;

/**
 * An abstract base class for Assets. An Asset is any component of a system that is used by Archimedes
 * during code generation. Each Asset is assigned an identifier as instatiation that can be used to keep track
 * of that asset.
 * 
 * @author Erik Gustavson
 * @version $Id: AbstractAsset.java 268 2005-04-12 02:25:03 +0000 (Tue, 12 Apr 2005) erik $
 *
 * Created on Oct 28, 2003
 */
public abstract class AbstractAsset implements Asset {

    private String identifier;

    protected Log  log = LogFactory.getLog(this.getClass());

    /**
     * Basic Constructor. Generates the unique identifier for this Asset.
     * This identifier doesn't have to be globally unique, just unique
     * for this run of Archimedes.
     */
    public AbstractAsset() {
        super();
        try {
            String seed = System.nanoTime() + "";
            identifier = GuidGenerator.generate(seed.getBytes());
        } catch (Exception e) {
            log.fatal("Could not generate identifier", e);
        }
    }

    /**
     * Returns a unique identifier for this asset. The identifier is generated at
     * instantiation time.
     * 
     * @see com.tps.filegen.model.Asset#getIdentifier()
     */
    public String getIdentifier() {
        return identifier;
    }

}